home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16307 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 100435.736@compuserve.com (David A. Mair)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Interrupt handlers in classes.
  5. Date: Wed, 10 Apr 1996 09:36:11 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4kfvef$s6k@arl-news-svc-4.compuserve.com>
  8. References: <316a9ea3.0@news.globalnet.co.uk>
  9. NNTP-Posting-Host: dd41-171.compuserve.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. barog@globalnet.co.uk (Barog) wrote:
  13.  
  14. >Please help I need to know how to put an interrupt handler in a class
  15. >and be able to set the interrupt handler to a vector with another
  16. >class member(Install_Handler()). 
  17.  
  18. You will have to make the interrupt handler a static member function
  19. since it will then have the correct linkage for the interrupt call.
  20. This means it will have no access to per instance data.  I normally
  21. gain that access by list of pointers to the class as a static member
  22. variable of the class.  Then, when I Install_Handler() I store the
  23. interrupt number with the value of this in the static list.  The
  24. interrupt handler then has to parse the list looking for the value of
  25. this for the interrupt it is servicing, then it can use per-instance
  26. data.  However, I can only see this being viable in hardware interrupt
  27. handlers because you can find out which interrupt was called.  You
  28. can't guarantee that you can check the instruction before the return
  29. address to get the interrupt number for a software interrupt and it is
  30. not possible to use the interrupt vector table to find the address of
  31. the function being executed.  Anyway, I have managed this sort of
  32. thing for comms handlers in the past, so it is possible.
  33.  
  34. Regards
  35. David.
  36.  
  37.  
  38.